<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateModelHasPaymentOrdersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('model_has_payment_orders', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('subject_id')->default(0)->comment('模型 ID');
            $table->char('subject_type', 64)->default('')->comment('模型');
            $table->unsignedBigInteger('payment_order_id')->index()->default(0)->comment('收银台订单 ID');
            $table->tinyInteger('type')->default(1)->comment('用来标注所属类型; 1:业务订单 2:渠道订单');

            $table->index(['subject_id', 'subject_type']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('model_has_payment_orders');
    }
}
